

package controller;




import bo.BUS_SanPham;
import com.opensymphony.xwork2.ActionSupport;
import dto.DTO_SanPham;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;




public class CapNhatSPAction extends ActionSupport implements ServletRequestAware {

    private String TenSP;
    private int GiaMua;
    private int GiaBan;
    private int LoaiSP;
    private int ChuDe;
    private int GioiTinh;
    private String HinhAnh;
    private String ThongTin;
    private HttpServletRequest request;
    public int getChuDe() {
        return ChuDe;
    }

    public void setChuDe(int ChuDe) {
        this.ChuDe = ChuDe;
    }

    public int getGiaBan() {
        return GiaBan;
    }

    public void setGiaBan(int GiaBan) {
        this.GiaBan = GiaBan;
    }

    public int getGiaMua() {
        return GiaMua;
    }

    public void setGiaMua(int GiaMua) {
        this.GiaMua = GiaMua;
    }

    public int getGioiTinh() {
        return GioiTinh;
    }

    public void setGioiTinh(int GioiTinh) {
        this.GioiTinh = GioiTinh;
    }

    public String getHinhAnh() {
        return HinhAnh;
    }

    public void setHinhAnh(String HinhAnh) {
        this.HinhAnh = HinhAnh;
    }

    public int getLoaiSP() {
        return LoaiSP;
    }

    public void setLoaiSP(int LoaiSP) {
        this.LoaiSP = LoaiSP;
    }

    public String getTenSP() {
        return TenSP;
    }

    public void setTenSP(String TenSP) {
        this.TenSP = TenSP;
    }

    public String getThongTin() {
        return ThongTin;
    }

    public void setThongTin(String ThongTin) {
        this.ThongTin = ThongTin;
    }

    public CapNhatSPAction() {

    }



    public String execute() throws Exception {

        int MaSP = Integer.parseInt(request.getParameter("MaSP"));
        BUS_SanPham busSP = new BUS_SanPham();
        DTO_SanPham sp = new DTO_SanPham();
        sp.setMaSP(MaSP);
        sp.setTenSP(TenSP);
        sp.setGiaMua(GiaMua);
        sp.setGiaBan(GiaBan);
        sp.setGioiTinh(GioiTinh);
        sp.setLoaiSP(LoaiSP);
        sp.setChuDe(ChuDe);
        sp.setHinhAnh(HinhAnh);
        sp.setThongTin(ThongTin);

        boolean flag = busSP.suasanpham(sp);
        if(flag == true)
        {
            return "success";
        }
        return "fail";

    }

    @Override
    public void setServletRequest(HttpServletRequest hsr) {
        request = hsr;
    }



}